extension FNumExtension on num {
  String formatHMS() {
    num seconds = this;
    int hours = seconds ~/ 3600;
    int minutes = (seconds % 3600) ~/ 60;
    int secs = (seconds % 60).toInt();
    return '${_twoDigits(hours)}:${_twoDigits(minutes)}:${_twoDigits(secs)}';
  }

  String formatHM() {
    num seconds = this;
    int hours = seconds ~/ 3600;
    int minutes = (seconds % 3600) ~/ 60;
    return '${_twoDigits(hours)}:${_twoDigits(minutes)}';
  }

  String formatMS() {
    num seconds = this;
    int minutes = (seconds % 3600) ~/ 60;
    int secs = (seconds % 60).toInt();
    return '${_twoDigits(minutes)}:${_twoDigits(secs)}';
  }

  String formatYMD() {
    DateTime date = DateTime.fromMillisecondsSinceEpoch(toInt());
    return '${date.year}/${_twoDigits(date.month)}/${_twoDigits(date.day)}';
  }

  String _twoDigits(num n) => n.toString().padLeft(2, '0');
}
